<template>
  <a-row type="flex" justify="center">
                <a-space :span="4">
                  <!-- <a-select
                    :default-value="sort_fields[0].id"
                    @change="SortFieldChange"
                  >
                    <a-select-option
                      :value="field.id"
                      v-for="(field, index) in sort_fields"
                      :key="index"
                    >
                      {{ field.name }}
                    </a-select-option>
                  </a-select>

                  <a-switch default-checked @change="SortTypeChange">
                    <a-icon slot="checkedChildren" type="up" />
                    <a-icon slot="unCheckedChildren" type="down" />
                  </a-switch> -->

                  <a-pagination
                    size="small"
                    showQuickJumper
                    showLessItems
                    :pageSize="page_size"
                    :showTotal="(total_counts) => `共 ${total_counts} 条记录`"
                    :default-current="page_current"
                    :current="page_current"
                    :total="total_counts"
                    @change="CurrentPageChange"
                    @showSizeChange="PageSizeChange"
                  />
                </a-space>
              </a-row>
</template>
<script>
export default {
  props: {
    sort_fields: Array,
    page_current: Number,
    total_counts: Number,
    page_size_default: Number,
    page_size_options: Array,
    page_size: Number,
  },

  data: () => ({}),
  components: {},
  methods: {
        // 分页 start
    SortTypeChange: function (checked) {
      if (checked) {
        this.$store.commit(
          this.$store.state.Namedparent.name + "/ChangeSortType",
          "asc"
        );
      } else {
        this.$store.commit(
          this.$store.state.Namedparent.name + "/ChangeSortType",
          "desc"
        );
      }
    },
    SortFieldChange: function (sortField) {
      this.$store.commit(
        this.$store.state.Namedparent.name + "/ChangeSortField",
        sortField
      );
    },
    CurrentPageChange: function (currentPage) {
      this.$store.commit(
        this.$store.state.Namedparent.name + "/Changeloading",
        true
      );
      this.$store.commit(
        this.$store.state.Namedparent.name + "/ChangeCurrentPage",
        currentPage
      );
      this.$store.dispatch(this.$store.state.Namedparent.name + "/GetBooks");
    },
    PageSizeChange: function (current, size) {
      if (current != size) {
        var pageSize = size;
        this.$store.commit(
          this.$store.state.Namedparent.name + "/ChangePageSize",
          pageSize
        );
        this.$store.dispatch(this.$store.state.Namedparent.name + "/GetBooks");
      }
    },
    // 分页 end
  },
};
</script>